package com.liqw.auto.bean;

import com.liqw.Constant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CustomInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println(Constant.getStepStr("CustomInstantiationAwareBeanPostProcessor.postProcessBeforeInitialization") + "CustomInstantiationAwareBeanPostProcessor - InstantiationAwareBeanPostProcessor.postProcessBeforeInitialization : " + beanName);
        return InstantiationAwareBeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println(Constant.getStepStr("CustomInstantiationAwareBeanPostProcessor.postProcessAfterInitialization") + "CustomInstantiationAwareBeanPostProcessor - InstantiationAwareBeanPostProcessor.postProcessAfterInitialization : " + beanName);
        return InstantiationAwareBeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }

    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        System.out.println(Constant.getStepStr("CustomInstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation") + "CustomInstantiationAwareBeanPostProcessor - InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation : " + beanName);
        return InstantiationAwareBeanPostProcessor.super.postProcessBeforeInstantiation(beanClass, beanName);
    }

    @Override
    public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
        System.out.println(Constant.getStepStr("CustomInstantiationAwareBeanPostProcessor.postProcessAfterInstantiation") + "CustomInstantiationAwareBeanPostProcessor - InstantiationAwareBeanPostProcessor.postProcessAfterInstantiation : " + beanName);
        return InstantiationAwareBeanPostProcessor.super.postProcessAfterInstantiation(bean, beanName);
    }

    @Override
    public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException {
        System.out.println(Constant.getStepStr("CustomInstantiationAwareBeanPostProcessor.postProcessProperties") + "CustomInstantiationAwareBeanPostProcessor - InstantiationAwareBeanPostProcessor.postProcessProperties : " + beanName);
        return InstantiationAwareBeanPostProcessor.super.postProcessProperties(pvs, bean, beanName);
    }
}